<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <title>MPlayer</title>
    <style type="text/less" scoped>
        .el-header {
            background-color: #31c27c;
            color: #333;
            line-height: 60px;
            font-size: 12px;
            display: flex;
            align-items: center;
            justify-content: flex-end;

            .el-avatar {
                display: flex;
                margin-right: 15px;
            }
            .el-menu-demo{
                margin-right: 50px;
            }
        }

        .el-footer {
            background-color: #B3C0D1;
            color: #333;
            text-align: center;
            line-height: 60px;
        }

        .el-aside {
            background-color: #D3DCE6;
            color: #333;
            text-align: center;
            line-height: 200px;
        }

        .el-main {
            background-color: #E9EEF3;
            color: #333;
            text-align: center;
            /*line-height: 160px;*/
        }

        body > .el-container {
            margin-bottom: 80px;
        }

        .el-container:nth-child(5).el-aside,
        .el-container:nth-child(6).el-aside {
            line-height: 260px;
        }

        .el-container:nth-child(7) .el-aside {
            line-height: 320px;
        }
    </style>
</head>
<body>
<div id="app">
    <el-container style="height: 100vh; border: 1px solid #eee">
        <el-aside width="200px" style="background-color: #D3DCE6;">
            <el-menu :default-openeds="['1', '3']">
                <el-submenu index="1">
                    <template slot="title"><i class="el-icon-headset"></i>在线音乐</template>
                    <el-menu-item-group>
                        <template slot="title">分组一</template>
                        <el-menu-item index="1-1">选项1</el-menu-item>
                        <el-menu-item index="1-2">选项2</el-menu-item>
                    </el-menu-item-group>
                    <el-menu-item-group title="分组2">
                        <el-menu-item index="1-3">选项3</el-menu-item>
                    </el-menu-item-group>
                    <el-submenu index="1-4">
                        <template slot="title">选项4</template>
                        <el-menu-item index="1-4-1">选项4-1</el-menu-item>
                    </el-submenu>
                </el-submenu>
                <el-submenu index="2">
                    <template slot="title"><i class="el-icon-user"></i>我的音乐</template>
                    <el-menu-item-group>
                        <template slot="title">分组一</template>
                        <el-menu-item index="2-1">选项1</el-menu-item>
                        <el-menu-item index="2-2">选项2</el-menu-item>
                    </el-menu-item-group>
                    <el-menu-item-group title="分组2">
                        <el-menu-item index="2-3">选项3</el-menu-item>
                    </el-menu-item-group>
                    <el-submenu index="2-4">
                        <template slot="title">选项4</template>
                        <el-menu-item index="2-4-1">选项4-1</el-menu-item>
                    </el-submenu>
                </el-submenu>
                <el-submenu index="3">
                    <template slot="title"><i class="el-icon-setting"></i>其他</template>
                    <el-menu-item-group>
                        <template slot="title">分组一</template>
                        <el-menu-item index="3-1">选项1</el-menu-item>
                        <el-menu-item index="3-2">选项2</el-menu-item>
                    </el-menu-item-group>
                    <el-menu-item-group title="分组2">
                        <el-menu-item index="3-3">选项3</el-menu-item>
                    </el-menu-item-group>
                    <el-submenu index="3-4">
                        <template slot="title">选项4</template>
                        <el-menu-item index="3-4-1">选项4-1</el-menu-item>
                    </el-submenu>
                </el-submenu>
            </el-menu>
        </el-aside>
        <el-container>
            <el-header>
                <!--头部导航菜单-->
                <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleMenu"
                         background-color="#31c27c" text-color="#3f3f3f" active-text-color="#ffdc00">
                    <el-menu-item index="1">排行榜</el-menu-item>
                    <el-submenu index="2">
                        <template slot="title">发现音乐</template>
                        <el-menu-item index="2-1">推荐</el-menu-item>
                        <el-menu-item index="2-2">歌单</el-menu-item>
                        <el-menu-item index="2-3">MV</el-menu-item>
                    </el-submenu>
                    <el-menu-item index="3">VIP</el-menu-item>
                    <el-menu-item index="4" disabled>求打赏</el-menu-item>
                </el-menu>
                <!-- 搜索-->
                <el-row class="demo-autocomplete">
                    <el-col :span="12">
                        <el-autocomplete
                                class="inline-input"
                                v-model="state"
                                :fetch-suggestions="querySearch"
                                placeholder="音乐/明星"
                                @select="handleSelect"
                        ></el-autocomplete>
                    </el-col>
                </el-row>
                <!--头像、用户名-->
                <el-dropdown>
                    <el-avatar src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"></el-avatar>
                    <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item>我的主页</el-dropdown-item>
                        <el-dropdown-item>vip会员</el-dropdown-item>
                        <el-dropdown-item>退出</el-dropdown-item>
                    </el-dropdown-menu>
                </el-dropdown>
                <span>王小虎</span>
            </el-header>

            <el-main>
                <el-table :data="tableData">

                    <el-table-column prop="name" label="歌手" width="120">
                    </el-table-column>
                    <el-table-column prop="address" label="歌曲">
                    </el-table-column>
                    <el-table-column prop="date" label="时长" width="140">
                    </el-table-column>
                </el-table>
            </el-main>


            <el-footer>Footer</el-footer>
        </el-container>
    </el-container>
</div>
</body>

<script src="js/vue.min.js"></script>
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/less.js/2.5.3/less.min.js"></script>

<script>
    var Main = {
        //数据
        data() {
            const item = {
                date: '03:33',
                name: '孙燕姿',
                address: '遇见'
            };
            return {
                tableData: Array(20).fill(item),
                state: '', //v-model 绑定搜索输入框
                restaurants: [],//搜索返回的数组
                activeIndex: '1', //头部导航菜单 选中索引？
            }
        },
        //方法
        methods: {
            querySearch(queryString, cb) {
                var restaurants = this.restaurants;
                var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
                // 调用 callback 返回建议列表的数据
                cb(results);
            },
            createFilter(queryString) {
                return (restaurant) => {
                    return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
                };
            },
            loadAll() {
                return [
                    {"value": "周杰伦"},
                    {"value": "梁静茹"},
                    {"value": "林俊杰"},
                    {"value": "王力宏"},
                    {"value": "五月天"},
                    {"value": "孙燕姿"},
                ];
            },
            //点击推荐明星或音乐
            handleSelect(item) {
                console.log(item);
            },
            //点击选择的头部导航菜单
            handleMenu(key, keyPath) {
                console.log(key, keyPath);
            },
        },
        //计算属性
        mounted() {
            this.restaurants = this.loadAll();
        }
    };
    var Ctor = Vue.extend(Main)
    new Ctor().$mount('#app')
</script>
</html>
